//package com.smedi.ismedi.authority.starter.aspect;
//
//import com.smedi.ismedi.authority.starter.constant.AuthorityConstant;
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.*;
//import org.springframework.context.annotation.Lazy;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//
//import javax.servlet.http.HttpServletRequest;
//
///**
// * @Author: xulinjun
// * @Date: 2021-7-8 13:43
// */
//@Aspect
//@Slf4j
//@Component
//@Lazy(value = false)
//@Order(value = 1)
//public class AuthorityAspect {
//    private HttpServletRequest getRequest() {
//        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
//        return request;
//    }
//
//    @Pointcut("@annotation(com.smedi.ismedi.authority.starter.annotation.SkipAuthority)")
//    private void cutExecute() {
//    }
//
//    /***
//     * 全过程
//     * @param pjp
//     * @return
//     */
//    @Around(value = "cutExecute()")
//    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
//        log.info("AuthorityAspect 开始执行方法 >>> {}", pjp.getSignature().getName());
//        Object[] params = pjp.getArgs();
//        for (Object param : params) {
//            log.info(" + 入参: {}", param);
//        }
//        return pjp.proceed(); // 执行代码
//    }
//
//    @Before(value = "cutExecute()")
//    public void doBefore() {
//        log.debug("
//
//        添加跨过安全验证");
//        log.debug("线程id：{}", Thread.currentThread().getId());
//        HttpServletRequest request = getRequest();
//        // todo 增加线程 + Thread 的父线程解决多线程
//        request.getSession().setAttribute(AuthorityConstant.skipAuthority, true);
//    }
//
//    @After(value = "cutExecute()")
//    public void doAfter() {
//        log.debug("删除跨过安全验证");
//        log.debug("线程id：{}", Thread.currentThread().getId());
//        HttpServletRequest request = getRequest();
//        request.getSession().removeAttribute(AuthorityConstant.skipAuthority);
//    }
//}